<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet"  type="text/css"  href="../../../../../lib/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet"  type="text/css" href="/css/goodslist.css">
    <link rel="stylesheet" href="/css/liandou.css">
</head>
<body>
<div class="goodslist-wrapper" style="padding: 0 30px 0 30px">
    <div>
        <ul class="nav nav-tabs" role="tablist">
            <li role="presentation" class="active"><a href="#allorder" >所有订单 <i>（{$list.order_num}）</i></a></li>
            <li role="presentation"><a href="#">充值订单<i>({$list.withdraw_num})</i></a></li>
            <li role="presentation"><a href="#" >提现订单<i>({$list.recharge_num})</i></a></li>
        </ul>
        <div class="row czrow" >
            <form class="col-sm-4 form-inline">
                <div class="form-group">
                    <input type="text" class="form-control"  placeholder="用户名/订单号">
                    <a href="javascript:; " class="btn btn-default">搜索</a>
                </div>
            </form>
            <div class="col-sm-4" style="line-height: 34px"><a href="javascript:window.location.reload();" style="margin-left: 20px;"><span class="glyphicon glyphicon-repeat" style="font-size: 16px"></span> </a> 刷新-共 <i>{$list.order_num}</i>条记录</div>
            <div class="col-sm-4">
                <!-- <a href="javascript:;" class="btn btn-default disabled"  id="del"><span class="glyphicon glyphicon-trash "></span>删除</a> -->
            </div>
        </div>
        <div class="tab-content">
            <table class="table "style="text-align: center">
                <thead style="border: 1px solid #BBBBBB;background-color:#eeeeee;" >
                <tr style="border-bottom: 1px solid #BBBBBB">
                    <td style="text-align: left"><!--<input type="checkbox" id="check-all" onclick="checkAll()">--><span style="margin-left: 10px">订单号</span></td>
                    <td>流水账号</td>
                    <td>手机号</td>
                    <td>订单操作前联豆数量</td>
                    <td>用户最新请求</td>
                    <td>订单操作后联豆数量</td>
                    <td>请求状况</td>
                    <td>备注</td>
                    <td>操作</td>
                </tr>
                </thead>
                <tbody>
                {volist name = "result" id = "value"}
                <tr>
                    <td >
                        <!-- <input type="checkbox">-->
                        <span class="order">{$value.order_num}</span><br>
                    </td>
                    <td>
                        {if $value.pay_staff == '1'}
                        <p class=""><i>{$value.bank_num}</i> </p>
                        <p><i>{$value.bank_name}</i><i>({$value.user_name})</i></p>
                        {elseif $value.pay_staff == '2'}
                        <p class=""><i>支付宝</i> </p>
                        {elseif $value.pay_staff == '3'}
                        <p class=""><i>微信</i> </p>
                        {/if}
                    </td>
                    <td>
                        <div class="phone">{$value.iphone}</div>
                    </td>
                    <td >
                        <div >{$value.beans_start_num}</div>
                    </td>
                    <td>
                        <div>
                            {if $value.user_staff == '1'}
                            <p><i class="blue">提现</i></p>
                            {else}
                            <p><i class="blue">充值</i></p>
                            {/if}
                            {if $value.user_staff == '1'}
                            <p>前端发起提现:{$value.beans_num}X90%=<i class="red">¥{$value.order_money}</i></p>
                            {else}
                            <p><i>{$value.beans_num}0</i>小钱包0.1元出=￥{$value.order_money}，兑换联豆 <i>{$value.beans_num}</i></p>
                            {/if}
                            <p style="color: #888;">请求时间：<i>{$value['create_time']}</i></p>
                        </div>
                    </td>
                    <td class="count">
                        {$value.beans_end_num}
                    </td>
                    <td>
                        {if $value.order_staff == '1'}
                        <span class="red">未受理</span>
                        {elseif $value.order_staff == '2'}
                        <span class="blue">受理中</span>
                        {elseif $value.order_staff == '4'}
                        <span class="blue">受理失败</span>
                        {else}
                        <p style="color: black">受理成功</p>
                        <p style="color: #888">{$value.update_time} </p>
                        {/if}
                    </td>
                    <td>
                        <input type="text" placeholder="请输入备注" class="border-dashed Remarks" value="{$value.remarks}">
                    </td>
                    <td>
                        <ul>
                            {if $value.user_staff == '2' && $value.order_staff == '1'}
                            <li><a href="{:url('beans/checkoutOrder', ['order_num' => $value.order_num, 'order_staff' => 3, 'user_staff' => $value.user_staff])}" class="btn btn-danger btn-xs">确认充值</a></li>
                            {elseif $value.user_staff == '2' && $value.order_staff == '2'}
                            <li><a href="javascript:;" class="btn btn-default btn-xs">充值中</a></li>
                            {elseif $value.user_staff == '2' && $value.order_staff == '3'}
                            <li><a href="javascript:;" class="btn btn-success btn-xs">充值完成</a></li>
                            {elseif $value.user_staff == '2' && $value.order_staff == '4'}
                            <li><a href="{:url('beans/checkoutOrder', ['order_num' => $value.order_num, 'order_staff' => 3, 'user_staff' => $value.user_staff])}" class="btn btn-default btn-xs">再次充值</a></li>
                            {elseif $value.user_staff == '1' && $value.order_staff == '1'}
                            <li><a href="{:url('beans/checkoutOrder', ['order_num' => $value.order_num, 'order_staff' => 3, 'user_staff' => $value.user_staff])}" class="btn btn-default btn-xs">折返用户</a></li>
                            {elseif $value.user_staff == '1' && $value.order_staff == '2'}
                            <li><a href="javascript:;" class="btn btn-info btn-xs">折返中</a></li>
                            {elseif $value.user_staff == '1' && $value.order_staff == '3'}
                            <li><a href="javascript:;" class="btn btn-success btn-xs">折返完成</a></li>
                            {elseif $value.user_staff == '1' && $value.order_staff == '4'}
                            <li><a href="{:url('beans/checkoutOrder', ['order_num' => $value.order_num, 'order_staff' => 3, 'user_staff' => $value.user_staff])}" class="btn btn-default btn-xs">再次折返</a></li>
                            {/if}
                            {if $value.order_staff == '1'}
                            <li><a href="javascipt:;" class="btn btn-default btn-xs editbtn" data-toggle="modal" data-target="#caozuomodel">操作</a></li>
                            {/if}
                            <li><a href="{:url('beans/beansUpdate', ['order_num' => $value.order_num])}" class="btn btn-default btn-xs">详情</a></li>
                            <!-- <li><a href="javascript:;" class="btn btn-default btn-xs">删除</a></li> -->
                        </ul>
                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>
        </div>
    </div>
</div>

<div class="modal fade" id="caozuomodel" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="exampleModalLabel">联豆管理-操作</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="update" method="post">
                    <div class="form-group">
                        <input type="text" hidden name="order_num" id="ordernumhide">
                        <input type="text" hidden name="phone" id="inputphone">
                        <label  class="col-sm-3 control-label" >订单号：</label><span class="col-sm-9 " id="ordernum" ></span>
                    </div>
                    <div class="form-group">
                        <label  class="col-sm-3 control-label" style="vertical-align: top">手机号：</label><span class="col-sm-9 " id="username" ></span>
                    </div>
                    <div class="form-group">
                        <label  class="col-sm-3 control-label" style="vertical-align: top">联豆数量：</label><span class="col-sm-9 " id="beancount" ></span>
                    </div>
                    <div class="form-group">
                        <label  class="col-sm-3 control-label">操作：</label>
                        <div class="col-sm-9">
                            <input type="text" class="textbox" id="textbox">
                            <button type="button" class="btn btn-info" id="add">增加</button>
                            <button type="button" class="btn  btn-info " id="cut">减少</button>
                        </div>
                    </div>
                    <div class="form-group">
                        <label  class="col-sm-3 control-label">操作后数量：</label>
                        <div class="col-sm-9">
                            <label id="text"></label>
                            <input type="text"  name="count" hidden>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="submit" class="btn btn-primary">确认操作</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script src="/lib/jquery/jquery.js"></script>
<script src="/lib/bootstrap/js/bootstrap.min.js"></script>
<script>
    $(".editbtn").each(function (index, item) {
        $(item).click(function () {
            $("#ordernum").html("");
            $("#ordernumhide").val("");
            $("#username").html("");
            $("#inputphone").val("");
            $("#beancount").html("");
            var ordernum=$($(".order").get(index)).html();
            var phone=$($(".phone").get(index)).html();
            var beancount=$($(".count").get(index)).html();
            $("#ordernum").html(ordernum);
            $("#ordernumhide").val(ordernum);
            $("#username").html(phone);
            $("#inputphone").val(phone);
            $("#beancount").html(beancount);
        })
    })

    /*计算书亮*/
    $("#add").click(function () {
        var beforeval=Number($("#beancount").html());
        var value=Number($("#textbox").val());

        if(!value)return;
        if(!/^\d+$/g.test(value)){
            alert("请输入数字！");
            return
        }

        $("#text").html(beforeval+value);
        $("input[name=count]").val(beforeval+value);
        console.log($("input[name=count]").val());
    });


    $("#cut").click(function () {
        var beforeval=Number($("#beancount").html());
        var value=Number($("#textbox").val());

        if(!value)return;
        if(!/^\d+$/g.test(value)){
            alert("请输入数字！");
            return
        }

        $("#text").html(beforeval-value);
        $("input[name=count]").val(beforeval-value);
    });

    /*没有值阻止提交*/

    $("button[type=submit]").click(function () {
        if(!$("input[name=count]").val()){
            alert("请输入增加或减少数量")
            return false
        }
    })


    /*ajax提交留言*/

    $(".Remarks").each(function (index,item) {
        var value="";
        $(this).focus(function () {
            value=$($(".Remarks").get(index)).val();
        });
        $(this).blur(function () {
            var valueafter=$($(".Remarks").get(index)).val();
            var order_num = $($(".order").get(index)).html();
            if(value!==valueafter){
                $.ajax({
                    url:"remarks",
                    data:{"remarks":valueafter, 'order_num':order_num},
                    type:"post",
                    success:function (val) {
                        console.log(val)
                    }
                })
            }
        })
    })
</script>
</body>
</html>